import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils, MyUtils


def demo(publish,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx",stepIdxListNot=[]):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
     #publish = rootPath
     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)


def moduleSL_duanzi():

    rootPath = 'E:/workspace/0_model/越南夏普/SL/SL端子/正面/'
    publish =  None #rootPath
    #publish =  rootPath
    dstProductsList=[
         #2
        "#2-12.0正A","#2-12.0正B",  "#2-12.0反A","#2-12.0反B",
        "#2-12.2正A","#2-12.2正B",  "#2-12.2反A","#2-12.2反B",
        

        #3
        #"#3正12.2","#3反12.2",
         "#3-16.3正A","#3-16.3正B",  "#3-16.3反A","#3-16.3反B",

                     ]
    stepIdxListNot = [0, 
       
                       ]


    #编辑参数####################################################
    srcProduct="#2-12.2反B"
    commitInfo = "添加#2-12.0"
    
    #编辑参数####################################################

    print("发布: ", publish)
    print("commitInfo: ", commitInfo)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct

    dstModelPathList = []
    for dstProducts in dstProductsList:
        dstModelPathList.append(rootPath+dstProducts+"/model-sl-electrode-check-"+dstProducts+"/")
    

    srcProductPath=rootPath+srcProduct+"/model-sl-electrode-check-"+srcProduct+"/"
    demo(publish=publish,srcProductPath=srcProductPath, 
        dstModelPathList=dstModelPathList,commitInfo=commitInfo,stepIdxListNot=stepIdxListNot)
    

if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    moduleSL_duanzi()

    exit(0)


    
